package com.example.smart.dialog

import android.content.Context
import android.view.Gravity
import android.view.View
import com.example.lib.extend.getDeviceWidth
import com.example.lib.extend.setOnDoubleClickListener
import com.example.smart.base.dialog.base.BaseDialog
import com.example.smart.databinding.DialogChooseLanguageBinding

class ChooseLanguageDialog(context: Context) : BaseDialog<DialogChooseLanguageBinding>(dialogContext = context,
    width = (getDeviceWidth(context) * 0.8).toInt(),
    gravity = Gravity.BOTTOM) {

    companion object {
        const val HAN = 0
        const val MENG = 1
    }

    var onClick: ((Int) -> Unit)? = null
    override fun setLayoutRes() = com.example.smart.R.layout.dialog_choose_language

    override fun afterViewCreate(view: View?) {
        banCancel()

        binding.DialogLanguageHan.setOnDoubleClickListener {
            onClick?.invoke(HAN)
        }

        binding.DialogLanguageMeng.setOnDoubleClickListener {
            onClick?.invoke(MENG)
        }
    }
}